apiready = function() {
    $('#sublogin').on('click', function() {
        var username = $("#account").val();
        var password = $("#password").val();
        if (!username || !password) {
            api.toast({
                msg: '用户名或密码不能为空',
                duration: 2000,
                location: 'bottom'
            });
            return;
        }

        $api.do_post("/api/commuser/login", {
            body: JSON.stringify({
                account: username,
                password: password
            })
        }, function(result) {
            if (result.code === 0) {
                if (result.entity) {
                    $api.setStorage('account', username);
                    $api.setStorage('password', password);
                    $api.setStorage('member', result.entity);
                    $api.setUserInf(result.entity);
                  
                    // api.closeToWin({
                    //     name: 'usercenter',
                    //     url: 'usercenter.html',
                    //     bounces: false,
                    // });
                   api.closeWin();
                } else {
                    console.error("登陆的Entity 为空");
                }
            }
            api.toast({
                msg: result.msg,
                duration: 2000,
                location: 'bottom'
            });
        });
    });

    $("#wxlogin").on('click', function() {
        api.openWin({
            name: 'reg',
            url: 'reg.html',
            bounces: false,
        });
    });
};